package day05;

import org.junit.Test;

import java.util.ArrayList;
import java.util.Collection;
import java.util.Iterator;

public class CollTest {



    @Test
    public void test(){
        Collection coll = new ArrayList();
        coll.add(123);
        coll.add(789);
        coll.add(new String("tom"));
        coll.add(new Person ("bob"));
        coll.add(false);

        Iterator iterator = coll.iterator();
        while(iterator.hasNext()){
            Object obj = iterator.next();
            if("tom".equals(obj)){
                iterator.remove();
            }
        }

        Iterator iterator1 = coll.iterator();
        while(iterator1.hasNext()){
            System.out.println(iterator1.next());
        }

    }

}

class Person{
    private String name;

    public Person(String name) {
        this.name = name;
    }

    public Person() {
    }

    public void show(){

         System.out.println(name);
    }

    @Override
    public String toString() {
        return "Person{" +
                "name='" + name + '\'' +
                '}';
    }
}


